[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Function            strins - insert one string into another

  Syntax              char *strins(char *source, char *new, char *ptr);

  Prototype in        stringhk.h

  Remarks             strins inserts the string new into the string
                      source at the location ptr in source. Basically,
                      strins copies source up to, but not including, ptr
                      into a new location, concatenates the new
                      (inserted) string, and then concatenates the
                      remainder of source (the string pointed to by ptr.)

  Return value        returns a pointer to the storage location
                      containing the newly concatenated string, or NULL
                      if space could not be allocated. The returned
                      string is NOT the same as the string passed to the
                      function. This function does NOT write over the
                      string passed to it.

  Example             #include <stringhk.h>
                      #include <stdio.h>            /* for the printf */

                      main()
                      {
                           char old[25], *ptr, *new;

                           strcpy(old,"ABCDEFG");
                           ptr = old + 3;            /* *ptr = 'D' */
                           new = strins(old,"abc",ptr);
                           printf("%s -> %s\n",old,new);
                      }

  Program output      ABCDEDFG -> ABCabcDEFG


See Also: strdel()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson